package com.gitee.wsl.ext.collection

fun Iterable<Double>.variance() = toList().toDoubleArray().let {
    val avg = it.average()
    asSequence().map { (it - avg).let { it * it } }.average()
}
fun Sequence<Double>.variance() = asIterable().variance()
fun Array<out Double>.variance() = asIterable().variance()
fun DoubleArray.variance() = asIterable().variance()

